IF EXISTS (select * From master.dbo.sysdatabases where name='NoteTable')
BEGIN
Drop Database[NoteTable]
END
CREATE Database[NoteTable]
GO

USE [NoteTable]
GO
/****** Object:  Table [dbo].[Role]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Role](
	[RoleId] [int] IDENTITY(1,1) NOT NULL,
	[RoleName] [nvarchar](50) NOT NULL,
	[RoleDescription] [nvarchar](256) NULL,
	[IsDeleted] [bit] NOT NULL,
 CONSTRAINT [PK_Role] PRIMARY KEY CLUSTERED 
(
	[RoleId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[User]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[User](
	[UserId] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](50) NOT NULL,
	[Email] [nvarchar](50) NOT NULL,
	[Password] [nvarchar](50) NOT NULL,
	[IsDeleted] [bit] NOT NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[User] ON
INSERT [dbo].[User] ([UserId], [UserName], [Email], [Password], [IsDeleted]) VALUES (1, N'admin', N'willdarwin@hotmail.com', N'HJKL:"', 0)
SET IDENTITY_INSERT [dbo].[User] OFF
/****** Object:  Table [dbo].[Authority]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Authority](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[IsController] [bit] NOT NULL,
	[IsAllowedNoneRoles] [bit] NOT NULL,
	[ControllerName] [nvarchar](50) NOT NULL,
	[IsAllowedAllRoles] [bit] NOT NULL,
 CONSTRAINT [PK_ControllerAction] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[UsersInRoles]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[UsersInRoles](
	[RoleId] [int] NOT NULL,
	[UserId] [int] NOT NULL,
 CONSTRAINT [PK_UsersInRoles] PRIMARY KEY CLUSTERED 
(
	[RoleId] ASC,
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[AuthorityRole]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AuthorityRole](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[IsAllowed] [bit] NOT NULL,
	[RoleId] [int] NOT NULL,
	[ControllerActionId] [int] NOT NULL,
 CONSTRAINT [PK_ControllerActionRole] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Analyzer]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Analyzer](
	[AnalyzerId] [int] IDENTITY(1,1) NOT NULL,
	[AnalyzerName] [nvarchar](50) NOT NULL,
	[CreateTime] [datetime] NOT NULL,
	[UserId] [int] NOT NULL,
	[SelectQuery] [nvarchar](max) NULL,
	[JoinQuery] [nvarchar](max) NULL,
	[WhereQuery] [nvarchar](max) NULL,
	[IsDeleted] [bit] NOT NULL,
 CONSTRAINT [PK_Analyzert] PRIMARY KEY CLUSTERED 
(
	[AnalyzerId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
/****** Object:  Table [dbo].[InvitationCode]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[InvitationCode](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Value] [nvarchar](50) NOT NULL,
	[Obsolete] [bit] NOT NULL,
	[UserId] [int] NULL,
 CONSTRAINT [PK_InvitationCode] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Idea]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Idea](
	[IdeaId] [int] IDENTITY(1,1) NOT NULL,
	[IdeaName] [nvarchar](50) NOT NULL,
	[IdeaDescription] [nvarchar](256) NULL,
	[CreateTime] [datetime] NOT NULL,
	[IsDeleted] [bit] NOT NULL,
	[UserId] [int] NOT NULL,
 CONSTRAINT [PK_Idea_1] PRIMARY KEY CLUSTERED 
(
	[IdeaId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
/****** Object:  Table [dbo].[ColumnInIdea]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ColumnInIdea](
	[ColumnId] [int] IDENTITY(1,1) NOT NULL,
	[ColumnName] [nvarchar](50) NOT NULL,
	[DataTypeId] [tinyint] NOT NULL,
	[ReferedIdeaId] [int] NOT NULL,
	[CreateTime] [datetime] NOT NULL,
	[IsDeleted] [bit] NOT NULL,
	[IdeaId] [int] NOT NULL,
 CONSTRAINT [PK_ColumnInIdea] PRIMARY KEY CLUSTERED 
(
	[ColumnId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
/****** Object:  Table [dbo].[U1_Row]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[U1_Row](
	[RowId] [int] IDENTITY(1,1) NOT NULL,
	[IdeaId] [int] NOT NULL,
	[Version] [int] NOT NULL,
	[IsDeleted] [bit] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[RowId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
/****** Object:  Table [dbo].[U1_ShortText]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[U1_ShortText](
	[ShortTextId] [int] IDENTITY(1,1) NOT NULL,
	[Value] [nvarchar](500) NULL,
	[ColumnId] [int] NOT NULL,
	[RowId] [int] NOT NULL,
	[IsDeleted] [bit] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[ShortTextId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
/****** Object:  Table [dbo].[U1_Number]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[U1_Number](
	[NumberId] [int] IDENTITY(1,1) NOT NULL,
	[Value] [decimal](18, 2) NULL,
	[ColumnId] [int] NOT NULL,
	[RowId] [int] NOT NULL,
	[IsDeleted] [bit] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[NumberId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
/****** Object:  Table [dbo].[U1_Money]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[U1_Money](
	[MoneyId] [int] IDENTITY(1,1) NOT NULL,
	[Value] [decimal](18, 2) NULL,
	[ColumnId] [int] NOT NULL,
	[RowId] [int] NOT NULL,
	[IsDeleted] [bit] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[MoneyId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
/****** Object:  Table [dbo].[U1_LongText]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[U1_LongText](
	[LongTextId] [int] IDENTITY(1,1) NOT NULL,
	[Value] [nvarchar](max) NULL,
	[ColumnId] [int] NOT NULL,
	[RowId] [int] NOT NULL,
	[IsDeleted] [bit] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[LongTextId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
/****** Object:  Table [dbo].[U1_Datetime]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[U1_Datetime](
	[DatetimeId] [int] IDENTITY(1,1) NOT NULL,
	[Value] [datetime] NULL,
	[ColumnId] [int] NOT NULL,
	[RowId] [int] NOT NULL,
	[IsDeleted] [bit] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[DatetimeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
/****** Object:  Table [dbo].[U1_ComplexType]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[U1_ComplexType](
	[ComplexTypeId] [int] IDENTITY(1,1) NOT NULL,
	[RefRowId] [int] NULL,
	[ColumnId] [int] NOT NULL,
	[RowId] [int] NOT NULL,
	[IsDeleted] [bit] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[ComplexTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
/****** Object:  Table [dbo].[ColumnInReference]    Script Date: 11/28/2013 09:58:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ColumnInReference](
	[ColumnId] [int] NOT NULL,
	[ReferedColumnId] [int] NOT NULL,
 CONSTRAINT [PK_ColumnInReference] PRIMARY KEY CLUSTERED 
(
	[ColumnId] ASC,
	[ReferedColumnId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
/****** Object:  Default [DF_Analyzert_IsDeleted]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[Analyzer] ADD  CONSTRAINT [DF_Analyzert_IsDeleted]  DEFAULT ((0)) FOR [IsDeleted]
GO
/****** Object:  Default [DF_ColumnInIdea_RIdeaType]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[ColumnInIdea] ADD  CONSTRAINT [DF_ColumnInIdea_RIdeaType]  DEFAULT ((0)) FOR [ReferedIdeaId]
GO
/****** Object:  Default [DF_ColumnInIdea_IsDeleted]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[ColumnInIdea] ADD  CONSTRAINT [DF_ColumnInIdea_IsDeleted]  DEFAULT ((0)) FOR [IsDeleted]
GO
/****** Object:  Default [DF_Idea_IsDeleted]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[Idea] ADD  CONSTRAINT [DF_Idea_IsDeleted]  DEFAULT ((0)) FOR [IsDeleted]
GO
/****** Object:  Default [DF_Role_IsDeleted]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[Role] ADD  CONSTRAINT [DF_Role_IsDeleted]  DEFAULT ((0)) FOR [IsDeleted]
GO
/****** Object:  Default [DF_User_IsDeleted]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[User] ADD  CONSTRAINT [DF_User_IsDeleted]  DEFAULT ((0)) FOR [IsDeleted]
GO
/****** Object:  ForeignKey [FK_Analyzer_User]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[Analyzer]  WITH CHECK ADD  CONSTRAINT [FK_Analyzer_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([UserId])
GO
ALTER TABLE [dbo].[Analyzer] CHECK CONSTRAINT [FK_Analyzer_User]
GO
/****** Object:  ForeignKey [FK_ControllerActionRole_ControllerAction]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[AuthorityRole]  WITH CHECK ADD  CONSTRAINT [FK_ControllerActionRole_ControllerAction] FOREIGN KEY([ControllerActionId])
REFERENCES [dbo].[Authority] ([Id])
GO
ALTER TABLE [dbo].[AuthorityRole] CHECK CONSTRAINT [FK_ControllerActionRole_ControllerAction]
GO
/****** Object:  ForeignKey [FK_ControllerActionRole_Role]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[AuthorityRole]  WITH CHECK ADD  CONSTRAINT [FK_ControllerActionRole_Role] FOREIGN KEY([RoleId])
REFERENCES [dbo].[Role] ([RoleId])
GO
ALTER TABLE [dbo].[AuthorityRole] CHECK CONSTRAINT [FK_ControllerActionRole_Role]
GO
/****** Object:  ForeignKey [FK_ColumnInIdea_Idea]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[ColumnInIdea]  WITH CHECK ADD  CONSTRAINT [FK_ColumnInIdea_Idea] FOREIGN KEY([IdeaId])
REFERENCES [dbo].[Idea] ([IdeaId])
GO
ALTER TABLE [dbo].[ColumnInIdea] CHECK CONSTRAINT [FK_ColumnInIdea_Idea]
GO
/****** Object:  ForeignKey [FK_ColumnInReference_ColumnInIdea]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[ColumnInReference]  WITH CHECK ADD  CONSTRAINT [FK_ColumnInReference_ColumnInIdea] FOREIGN KEY([ColumnId])
REFERENCES [dbo].[ColumnInIdea] ([ColumnId])
GO
ALTER TABLE [dbo].[ColumnInReference] CHECK CONSTRAINT [FK_ColumnInReference_ColumnInIdea]
GO
/****** Object:  ForeignKey [FK_ColumnInReference_ColumnInIdea1]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[ColumnInReference]  WITH CHECK ADD  CONSTRAINT [FK_ColumnInReference_ColumnInIdea1] FOREIGN KEY([ReferedColumnId])
REFERENCES [dbo].[ColumnInIdea] ([ColumnId])
GO
ALTER TABLE [dbo].[ColumnInReference] CHECK CONSTRAINT [FK_ColumnInReference_ColumnInIdea1]
GO
/****** Object:  ForeignKey [FK_Idea_User]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[Idea]  WITH CHECK ADD  CONSTRAINT [FK_Idea_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([UserId])
GO
ALTER TABLE [dbo].[Idea] CHECK CONSTRAINT [FK_Idea_User]
GO
/****** Object:  ForeignKey [FK_InvitationCode_User]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[InvitationCode]  WITH CHECK ADD  CONSTRAINT [FK_InvitationCode_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([UserId])
GO
ALTER TABLE [dbo].[InvitationCode] CHECK CONSTRAINT [FK_InvitationCode_User]
GO
/****** Object:  ForeignKey [FK__U1_Comple__Colum__4316F928]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_ComplexType]  WITH CHECK ADD FOREIGN KEY([ColumnId])
REFERENCES [dbo].[ColumnInIdea] ([ColumnId])
GO
/****** Object:  ForeignKey [FK__U1_Comple__RowId__440B1D61]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_ComplexType]  WITH CHECK ADD FOREIGN KEY([RowId])
REFERENCES [dbo].[U1_Row] ([RowId])
GO
/****** Object:  ForeignKey [FK__U1_Dateti__Colum__412EB0B6]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_Datetime]  WITH CHECK ADD FOREIGN KEY([ColumnId])
REFERENCES [dbo].[ColumnInIdea] ([ColumnId])
GO
/****** Object:  ForeignKey [FK__U1_Dateti__RowId__4222D4EF]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_Datetime]  WITH CHECK ADD FOREIGN KEY([RowId])
REFERENCES [dbo].[U1_Row] ([RowId])
GO
/****** Object:  ForeignKey [FK__U1_LongTe__Colum__3F466844]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_LongText]  WITH CHECK ADD FOREIGN KEY([ColumnId])
REFERENCES [dbo].[ColumnInIdea] ([ColumnId])
GO
/****** Object:  ForeignKey [FK__U1_LongTe__RowId__403A8C7D]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_LongText]  WITH CHECK ADD FOREIGN KEY([RowId])
REFERENCES [dbo].[U1_Row] ([RowId])
GO
/****** Object:  ForeignKey [FK__U1_Money__Column__3D5E1FD2]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_Money]  WITH CHECK ADD FOREIGN KEY([ColumnId])
REFERENCES [dbo].[ColumnInIdea] ([ColumnId])
GO
/****** Object:  ForeignKey [FK__U1_Money__RowId__3E52440B]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_Money]  WITH CHECK ADD FOREIGN KEY([RowId])
REFERENCES [dbo].[U1_Row] ([RowId])
GO
/****** Object:  ForeignKey [FK__U1_Number__Colum__3B75D760]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_Number]  WITH CHECK ADD FOREIGN KEY([ColumnId])
REFERENCES [dbo].[ColumnInIdea] ([ColumnId])
GO
/****** Object:  ForeignKey [FK__U1_Number__RowId__3C69FB99]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_Number]  WITH CHECK ADD FOREIGN KEY([RowId])
REFERENCES [dbo].[U1_Row] ([RowId])
GO
/****** Object:  ForeignKey [FK__U1_Row__IdeaId__38996AB5]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_Row]  WITH CHECK ADD FOREIGN KEY([IdeaId])
REFERENCES [dbo].[Idea] ([IdeaId])
GO
/****** Object:  ForeignKey [FK__U1_ShortT__Colum__398D8EEE]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_ShortText]  WITH CHECK ADD FOREIGN KEY([ColumnId])
REFERENCES [dbo].[ColumnInIdea] ([ColumnId])
GO
/****** Object:  ForeignKey [FK__U1_ShortT__RowId__3A81B327]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[U1_ShortText]  WITH CHECK ADD FOREIGN KEY([RowId])
REFERENCES [dbo].[U1_Row] ([RowId])
GO
/****** Object:  ForeignKey [FK_UsersInRoles_Role]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[UsersInRoles]  WITH CHECK ADD  CONSTRAINT [FK_UsersInRoles_Role] FOREIGN KEY([RoleId])
REFERENCES [dbo].[Role] ([RoleId])
GO
ALTER TABLE [dbo].[UsersInRoles] CHECK CONSTRAINT [FK_UsersInRoles_Role]
GO
/****** Object:  ForeignKey [FK_UsersInRoles_User]    Script Date: 11/28/2013 09:58:53 ******/
ALTER TABLE [dbo].[UsersInRoles]  WITH CHECK ADD  CONSTRAINT [FK_UsersInRoles_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([UserId])
GO
ALTER TABLE [dbo].[UsersInRoles] CHECK CONSTRAINT [FK_UsersInRoles_User]
GO
